<template>
  <div class="shop">
    <el-button
      style="  position: absolute;left:20px;top: 40px;"
      size="mini"
      type="primary"
      @click="addPartner"
    >新增合伙人</el-button>
    <el-button
      style="float:right;margin-top:20px;"
      size="mini"
      type="primary"
      @click="searchArea"
    >搜索</el-button>
    <el-input
      style="float:right;width:164px;margin-top:20px;"
      size="mini"
      placeholder="输入合伙人账号搜索"
      v-model="mobile"
    ></el-input>
    <el-select
      style="width:130px;float:right;margin-top:20px;margin-right:12px;"
      v-model="region_id"
      size="mini"
      filterable
      placeholder="区/县"
    >
      <el-option v-for="item in areaList" :key="item.id" :label="item.name" :value="item.id"></el-option>
    </el-select>
    <el-select
      style="width:130px;float:right;margin-top:20px;"
      v-model="city_id"
      size="mini"
      filterable
      placeholder="市"
      @change="onChangeCity"
    >
      <el-option v-for="item in cityList" :key="item.id" :label="item.name" :value="item.id"></el-option>
    </el-select>
    <el-select
      style="width:130px;float:right;margin-top:20px;"
      v-model="province_id"
      size="mini"
      filterable
      placeholder="省"
      @change="onChangeProvince"
    >
      <el-option v-for="item in provinceList" :key="item.id" :label="item.name" :value="item.id"></el-option>
    </el-select>

    <span style="float:right;margin-top:24px;color:#666;margin-right:8px;margin-left:12px;">所属区域</span>

    <el-select
      style="width:130px;float:right;margin-top:20px;"
      v-model="status"
      size="mini"
      filterable
    >
      <el-option value="1" label="正常"></el-option>
      <el-option value="2" label="审核中"></el-option>
      <el-option value="0" label="禁用"></el-option>
    </el-select>
    <span style="float:right;margin-top:24px;color:#666;margin-right:8px;">账号状态</span>

    <el-select
      style="width:130px;float:right;margin-top:20px;"
      v-model="type"
      size="mini"
      filterable
      clearable
      placeholder="是否特通"
    >
      <el-option value="1" label="特通"></el-option>
      <el-option value="2" label="非特通"></el-option>
    </el-select>
    <el-table
      :data="tableData"
      style="width:100%;margin:40px 0;"
      max-height="680"
      :cell-style="tc"
      :header-cell-style="tccolor"
    >
      <el-table-column label="ID" prop="id"></el-table-column>
      <el-table-column label="合伙人账号" prop="mobile"></el-table-column>
      <el-table-column label="管理区域" width="280">
        <template slot-scope="scope">
          <template v-if="!scope.row.is_direct">
            {{scope.row.province}}.{{scope.row.city}}.{{scope.row.region}}
            <span
              style="cursor:pointer;color:#f4222d;"
              @click="watchAllAreas(scope.row.uid)"
            >(查看全部)</span>
          </template>
        </template>
      </el-table-column>
      <el-table-column label="联系人" prop="self_name">
        <template slot-scope="scope">
          <p v-if="scope.row.partner_type == 1">{{scope.row.company_contact}}</p>
          <p v-if="scope.row.partner_type == 2">{{scope.row.self_name}}</p>
          <p v-if="scope.row.partner_type == 0">待定</p>
        </template>
      </el-table-column>
      <el-table-column label="入驻时间" prop="create_at"></el-table-column>
      <!-- <el-table-column label="直邀乐粉">
      <template slot-scope="scope">
         {{scope.row.fans_count}}<span style="cursor:pointer;color:#f4222d;" v-if="scope.row.fans_count != 0" @click="watchFans(scope.row.uid)">(查看)</span>
      </template>
    </el-table-column>
    <el-table-column label="直邀小店">
      <template slot-scope="scope">
         {{scope.row.shop_count}}<span style="cursor:pointer;color:#f4222d;" v-if="scope.row.shop_count != 0" @click="watchShop(scope.row.uid)">(查看)</span>
      </template>
    </el-table-column>
    <el-table-column label="直邀服务商" width="100">
      <template slot-scope="scope">
         {{scope.row.invitation_count}}<span style="cursor:pointer;color:#f4222d;" v-if="scope.row.invitation_count != 0" @click="watchInvitation(scope.row.uid)">(查看)</span>
      </template>
      </el-table-column>-->
      <el-table-column label="合伙人状态">
        <template slot-scope="scope">
          <p v-if="scope.row.status == 0" style="color:red">禁用</p>
          <p v-if="scope.row.status == 1" style="color:green">正常</p>
          <p v-if="scope.row.status == 2">审核中</p>
        </template>
      </el-table-column>
      <el-table-column label="操作" fixed="right" width="480">
        <template slot-scope="scope">
          <el-button size="mini" @click="editAreaDetail(scope.row.id)">编辑</el-button>
          <el-button size="mini" @click="watchWhaleStore(scope.row.uid)">幕后街</el-button>
          <el-button size="mini" @click="watchServiceOrder(scope.row.uid)">服务订单</el-button>
          <el-button size="mini" @click="showRedpacketList(scope.row)">红包记录</el-button>
          <el-button size="mini" @click="watchSonAccount(scope.row.uid)">子账号</el-button>
          <el-button size="mini" @click="disableAreaPeopleJudge(scope.row.uid)">
            <span
              :style="scope.row.status == 0 ?'color:green':'color:red'"
            >{{scope.row.status == 0 ? '启用':'禁用'}}</span>
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <div class="pagination">
      <el-pagination
        background
        @current-change="pageChange"
        :current-page="page"
        :page-size="size"
        layout="total, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>

    <jdialog title="新增合伙人" :visible.sync="showAddpartner" width="640px">
      <div style="padding:20px;">
        <div style="margin-bottom:20px;">
          <span style="color:red;margin-right:4px;">*</span>
          <span style="margin-right:12px;">合伙人类型:</span>
          <el-radio v-model="partner_type" label="1" @change="changeRadio">企业</el-radio>
          <el-radio v-model="partner_type" label="2" @change="changeRadio">个人</el-radio>
        </div>
        <div style="margin-bottom:20px;">
          <span style="color:red;margin-right:4px;">*</span>
          <span style="margin-right:12px;">是否特通:</span>
          <el-radio v-model="is_direct" label="1" @change="changeDirect">是</el-radio>
          <el-radio v-model="is_direct" label="2" @change="changeDirect">否</el-radio>
        </div>
        <div style="margin-bottom:20px;" v-if="!isDirect">
          <span style="color:red;margin-right:4px;">*</span>
          <span style="margin-right:12px;">代理区域:</span>
          <div v-if="region_id_arr.count != 0">
            <div
              v-for="(name,index) in region_arr"
              :key="'p'+index"
              style="border:1px solid #999;margin-left:96px;text-align:center;height:28px;line-height:28px;margin-bottom:12px;width:270px;  border-radius: 4px;"
            >
              {{province_arr[index]}}.{{city_arr[index]}}.{{region_arr[index]}}
              <i
                class="el-icon-remove-outline"
                @click="detailSelect(index)"
              ></i>
            </div>
          </div>
          <el-button size="mini" style="margin-left:96px;" @click="selectPartnerArea">请选择代理区域</el-button>
        </div>
        <div style="margin-bottom:20px;">
          <span style="color:red;margin-right:4px;">*</span>
          <span style="margin-right:12px;">合伙人账号:</span>
          <el-input size="mini" style="width:320px;" placeholder="请输入合伙人账号" v-model="username"></el-input>
        </div>
        <div v-show="isCompany" style="margin-bottom:20px;">
          <span style="margin-right:12px;margin-left:24px;">公司名称:</span>
          <el-input size="mini" style="width:320px;" placeholder="请输入公司名称" v-model="company_name"></el-input>
        </div>
        <div v-show="isCompany" style="margin-bottom:20px;">
          <span style="margin-right:12px;margin-left:24px;">法人姓名:</span>
          <el-input
            size="mini"
            style="width:320px;"
            placeholder="请输入法人姓名"
            v-model="company_legalname"
          ></el-input>
        </div>
        <div style="margin-bottom:20px;">
          <span style="margin-right:12px;margin-left:36px;">联系人:</span>
          <el-input size="mini" style="width:140px;" placeholder="请输入联系人" v-model="company_contact"></el-input>
          <span style="margin-right:12px;margin-left:24px;">联系电话:</span>
          <el-input size="mini" style="width:140px;" placeholder="请输入电话" v-model="company_phone"></el-input>
        </div>
        <div style="margin-bottom:20px;">
          <span style="margin-right:12px;margin-left:24px;">联系住址:</span>
          <el-select
            style="width:120px;"
            v-model="province_id_address"
            size="mini"
            filterable
            placeholder="省"
            @change="onChangeProForAddress"
          >
            <el-option
              v-for="item in provinceList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
          <el-select
            style="width:120px;"
            v-model="city_id_address"
            size="mini"
            filterable
            placeholder="市"
            @change="onChangeCiAddress"
          >
            <el-option
              v-for="item in city_id_address_list"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>

          <el-select
            style="width:120px;"
            v-model="region_id_address"
            size="mini"
            filterable
            placeholder="区/县"
          >
            <el-option
              v-for="item in region_id_address_list"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
          <el-input size="mini" style="width:140px;" placeholder="请输入详细地址" v-model="address"></el-input>
        </div>
        <div style="margin-bottom:20px;">
          <span style="color:red;margin-right:4px;margin-left:24px;">*</span>
          <span style="margin-right:12px;">加盟费:</span>
          <el-input size="mini" style="width:100px;" v-model="initial_money"></el-input>
          <span style="margin-right:12px;margin-left:12px;">实收款:</span>
          <el-input size="mini" style="width:100px;" v-model="actual_money"></el-input>
          <span style="margin-right:12px;margin-left:12px;">待收款:</span>
          <el-input size="mini" style="width:100px;" v-model="wait_money"></el-input>
        </div>
        <div style="margin-bottom:20px;">
          <div style="float:left;">
            <span style="color:red;margin-right:4px;margin-left:24px;">*</span>
            <span style="margin-right:12px;">身份证:</span>
          </div>
          <uploadImg
            flieName="self_front_card"
            class="icon_cate"
            :oldImgs="[self_front_card]"
            :n="1"
            @getFile="getFile"
          ></uploadImg>

          <div v-show="isCompany" style="float:left;">
            <span style="margin-right:12px;margin-left:64px;">营业执照:</span>
          </div>
          <uploadImg
            v-show="isCompany"
            flieName="company_license"
            class="icon_cate"
            :oldImgs="[company_license]"
            :n="1"
            @getFile="getFile"
          ></uploadImg>
        </div>

        <div style="text-align:center;margin-top:160px;">
          <el-button size="mini" type="primary" @click="certainAddPartner">确定</el-button>
          <el-button size="mini" @click="cancelAddPartner">取消</el-button>
        </div>
      </div>
    </jdialog>

    <jdialog title="请选择代理区域" :visible.sync="showDailiArea" width="480px">
      <div style="height:560px;width:100%;">
        <div style="width:140px;height:100%;background-color:#f5f5f5;float:left;">
          <div
            v-for="(item,index) in provinceList"
            :key="'s'+index"
            style="width:100%;height:42px;text-align:center;line-height:42px;cursor:pointer;"
            @click="onChangeDailiProvinceId(item.id,item.name)"
          >
            <div
              style="float:left;width:4px;height:100%;background-color:#f4222d;"
              v-if="province_add_id == item.id"
            ></div>
            {{item.name}}
            <p style="color:#999;float:right;">></p>
          </div>
        </div>

        <div style="width:160px;height:100%;float:left;">
          <div
            v-for="(item,index) in city_add_list"
            :key="'c'+index"
            style="width:100%;height:42px;text-align:center;line-height:42px;cursor:pointer;"
            @click="onChangeDailiCityId(item.id,item.name)"
          >
            {{item.name}}
            <p style="color:#999;float:right;">></p>
          </div>
        </div>

        <div style="width:180px;height:100%;float:left;">
          <div
            v-for="(item,index) in regin_add_list"
            :key="'r'+index"
            style="width:100%;height:42px;text-align:center;line-height:42px;"
          >
            {{item.name}}
            <div
              style="background-color:#fff;float:right;border:2px solid #f4222d;color:#f4222d;width:14px;height:14px;margin-top:15px;margin-right:12px;cursor:pointer;"
              v-if="region_add_id==item.id"
            >
              <i class="el-icon-check"></i>
            </div>
            <div
              style="background-color:#fff;float:right;border:2px solid #f4222d;width:14px;height:14px;margin-top:15px;margin-right:12px;cursor:pointer;"
              v-else
              @click="selectPartnerRegion(item.id,item.name)"
            ></div>
          </div>
        </div>
      </div>
    </jdialog>

    <!--展示全部区域-->
    <jdialog :title="addTitle" :visible.sync="isShowAddRecharge" width="400px">
      <div>
        <div v-for="(item,index) in areaMangerList" :key="index" class="forAreas">
          <span>{{index+1}}</span>
          {{item.province}}-{{item.city}}-{{item.region}}
        </div>
      </div>
    </jdialog>

    <jdialog title="红包充值记录" :visible.sync="isShowRedpacketList" width="1000px">
      <redpacket :formData.sync="userForm"></redpacket>
    </jdialog>
  </div>
</template>

<script>
// import redpacket from "@/components/redpacket";
// import {
//   adminPartnerSearch,
//   addAdminPartner,
//   partnerProvinceAreas,
//   updataStatusPartner
// } from "@/api/service.js";
// import { provinceCityArea } from "@/api/goods";
// import uploadImg from "@/components/uploadImg";
export default {
  components: {
    // uploadImg,
    // redpacket
  },
  created() {},
  mounted() {
    //  this.provinceId = this.$route.query.region_id
    this.getProvinceDataList("1", "0");
    this.getpartnerProvinceSearchData();
  },
  data() {
    return {
      province_id: "",
      city_id: "",
      region_id: "",
      mobile: "",
      status: "",
      tableData: [],
      total: 0,
      page: 1,
      size: 20,

      areaList: [],
      cityList: [],
      provinceList: [],

      isShowAddRecharge: false,
      //新增合伙人
      showAddpartner: false,
      //合伙人类型
      partner_type: "",
      //合伙人账号
      username: "",
      //公司名称
      company_name: "",
      //法人姓名
      company_legalname: "",
      //联系人
      company_contact: "",
      //联系电话
      company_phone: "",
      //地址
      province_id_address: "",
      city_id_address_list: [],
      city_id_address: "",
      region_id_address_list: [],
      region_id_address: "",
      address: "",
      //加盟费
      initial_money: "",
      actual_money: "",
      wait_money: "",
      company_license: "",
      self_front_card: "",

      //代理区域
      showDailiArea: false,
      addTitle: "代理区域详情",
      areaMangerList: [],
      region_id_arr: [],
      region_arr: [],

      city_id_arr: [],
      city_arr: [],

      province_id_arr: [],
      province_arr: [],

      province_add_id: "",
      province_add_name: "",

      city_add_id: "",
      city_add_name: "",
      city_add_list: [],

      region_add_id: "",
      region_add_name: "",
      regin_add_list: [],
      // 添加合伙人
      isCompany: true,
      is_direct: "2",
      isDirect: false,
      type: undefined,
      userForm: {
        id: 0
      },
      isShowRedpacketList: false,
    };
  },
  methods: {
    changeRadio(e) {
      if (e == 1) {
        this.isCompany = true;
      } else {
        this.isCompany = false;
      }
    },
    changeDirect(e) {
      // alert(e)
      if (e == 1) {
        this.isDirect = true;
      } else {
        this.isDirect = false;
      }
    },
    pageChange(page) {
      this.page = page;
      this.getpartnerProvinceSearchData();
    },
    searchArea() {
      this.page = 1;
      this.getpartnerProvinceSearchData();
    },
    onChangeProvince(id) {
      this.city_id = this.region_id = "";
      this.getProvinceDataList("2", id);
    },
    onChangeCity(id) {
      this.region_id = "";
      this.getProvinceDataList("3", id);
    },
    async getProvinceDataList(t, p) {
      let res = await provinceCityArea({ type: t, pid: p });

      if (res.code === 10000) {
        if (t === "1") {
          this.provinceList = res.data;
          if (this.provinceList.length > 0) {
            this.province_add_id = this.provinceList[0].id;
            this.province_add_name = this.provinceList[0].name;
            this.getProvinceDataListAddDaili("2", this.province_add_id);
          }
        } else if (t === "2") {
          this.cityList = res.data;
        } else {
          this.areaList = res.data;
        }
      }
    },
    //获取列表接口
    async getpartnerProvinceSearchData() {
      var url = {
        city_id: this.city_id,
        region_id: this.region_id,
        mobile: this.mobile,
        page: this.page,
        status: this.status,
        type: this.type
      };
      let res = await adminPartnerSearch(url);
      if (res.code === 10000) {
        this.tableData = res.data.data;
        this.total = res.data.total;
      } else {
        this.$message.error(res.message);
      }
    },
    // 查看全部管理区域
    async watchAllAreas(id) {
      let res = await partnerProvinceAreas(id);
      console.log(res);
      this.isShowAddRecharge = true;
      this.areaMangerList = res.data;
    },
    //幕后街
    watchWhaleStore(id) {
      this.$router.push({
        // path: "./../management/shoplist",
        // query: { serviceId: id }
        name: "management_shoplist",
        params: { serviceId: id }
      });
    },
    //服务订单
    watchServiceOrder(id) {
      this.$router.push({
        path: "./isServiceOrder",
        query: { serviceId: id }
      });
    },
    //红包记录
    watchRedpacketRecord(id) {
      this.$router.push({
        path: "./ispRedPacket",
        query: { serviceId: id }
      });
    },
    watchFans(id) {
      this.$router.push({
        path: "./ispAreaDetailFanshopPar",
        query: {
          serviceId: id,
          type: "third"
        }
      });
    },
    watchShop(id) {
      this.$router.push({
        path: "./ispAreaDetailFanshopPar",
        query: {
          serviceId: id,
          type: "first"
        }
      });
    },
    watchInvitation(id) {
      this.$router.push({
        path: "./ispAreaDetailFanshopPar",
        query: {
          serviceId: id,
          type: "second"
        }
      });
    },
    //编辑
    editAreaDetail(id) {
      this.$router.push({
        path: "./ispAreaPartnerEditdetail",
        query: {
          partner_id: id
        }
      });
    },
    //子账号
    watchSonAccount(id) {
      this.$router.push({
        path: "./ispAreaChildrenAccount",
        query: {
          uid: id
        }
      });
    },
    //禁用
    async disableAreaPeople(uid) {
      var data = {
        uid: uid
      };
      let res = await updataStatusPartner(data);
      if (res.code == 10000) {
        this.getpartnerProvinceSearchData();
      } else {
        this.$message.error(res.message);
      }
    },
    async disableAreaPeopleJudge(uid) {
      this.$confirm("确认禁用该合伙人吗", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.disableAreaPeople(uid);
        })
        .catch(() => {});
    },

    //新增合伙人
    addPartner() {
      this.showAddpartner = true;
    },

    onChangeProForAddress(id) {
      this.city_id_address = this.region_id_address = "";
      this.getProvinceDataListAddress("2", id);
    },
    onChangeCiAddress(id) {
      this.region_id_address = "";
      this.getProvinceDataListAddress("3", id);
    },

    async getProvinceDataListAddress(t, p) {
      let res = await provinceCityArea({ type: t, pid: p });
      if (res.code === 10000) {
        if (t === "1") {
          this.provinceList = res.data;
        } else if (t === "2") {
          this.city_id_address_list = res.data;
        } else {
          this.region_id_address_list = res.data;
        }
      }
    },
    selectPartnerArea() {
      this.showDailiArea = true;
    },
    selectPartnerRegion(id, name) {
      if (this.region_id_arr.length < 100) {
        if (this.region_id_arr.length == 0) {
          this.region_add_id = id;
          this.region_add_name = name;

          this.region_id_arr.push(id);
          this.region_arr.push(name);

          this.city_id_arr.push(this.city_add_id);
          this.city_arr.push(this.city_add_name);

          this.province_id_arr.push(this.province_add_id);
          this.province_arr.push(this.province_add_name);

          this.showDailiArea = false;
        } else {
          if (this.region_id_arr.indexOf(id) == -1) {
            this.region_add_id = id;
            this.region_add_name = name;

            this.region_id_arr.push(id);
            this.region_arr.push(name);

            this.city_id_arr.push(this.city_add_id);
            this.city_arr.push(this.city_add_name);

            this.province_id_arr.push(this.province_add_id);
            this.province_arr.push(this.province_add_name);

            this.showDailiArea = false;
          } else {
            this.$message.error("不能添加相同的代理区域");
          }
        }
      } else {
        this.$message.error("所选代理区域不能超出100个");
      }
    },
    //删除所选代理区域
    detailSelect(index) {
      this.region_add_id = "";
      this.region_add_name = "";
      this.region_id_arr.splice(index, 1);
      this.region_arr.splice(index, 1);
      this.province_arr.splice(index, 1);
      this.province_id_arr.splice(index, 1);
      this.city_arr.splice(index, 1);
      this.city_id_arr.splice(index, 1);
    },
    //新增合伙人
    certainAddPartner() {
      if (!this.partner_type) {
        this.$message.error("请选择合伙人类型");
        return;
      }

      if(this.isDirect) {
        //特通
      } else {
        if (this.region_arr.length == 0) {
          this.$message.error("请选择代理区域");
          return;
        }

      }


      if (!this.username) {
        this.$message.error("合伙人账号不能为空");
        return;
      }

      if (!this.self_front_card) {
        this.$message.error("身份证不能为空");
        return;
      }

      if (!this.initial_money) {
        this.$message.error("加盟费不能为空");
        return;
      }
      if (!this.actual_money) {
        this.$message.error("实收款不能为空");
        return;
      }
      if (!this.wait_money) {
        this.$message.error("待收款不能为空");
        return;
      }

      if (!this.region_id_address) {
        this.$message.error("地址不能为空");
        return;
      }
      this.getaddAdminPartnerData();
    },
    cancelAddPartner() {
      this.showAddpartner = false;
      this.partner_type = "";
      //合伙人账号
      this.username = "";
      //公司名称
      this.company_name = "";
      //法人姓名
      this.company_legalname = "";
      //联系人
      this.company_contact = "";
      //联系电话
      this.company_phone = "";
      //地址
      this.province_id_address = "";
      this.city_id_address_list = [];
      this.city_id_address = "";
      this.region_id_address_list = [];
      this.region_id_address = "";
      this.address = "";
      //加盟费
      this.initial_money = "";
      this.actual_money = "";
      this.wait_money = "";
      this.company_license = "";
      this.self_front_card = "";

      //代理区域
      this.province_add_id = this.provinceList[0].id;
      this.province_add_name = this.provinceList[0].name;

      this.region_id_arr = [];
      this.region_arr = [];
      this.region_add_id = "";
      this.region_add_name = "";

      this.province_id_arr = [];
      this.province_arr = [];

      this.city_id_arr = [];
      this.city_arr = [];
      this.city_add_id = "";
      this.city_add_name = "";

      this.getProvinceDataListAddDaili("2", this.province_add_id);
    },
    onChangeDailiProvinceId(id, name) {
      this.province_add_id = id;
      this.province_add_name = name;
      this.regin_add_list = [];
      this.getProvinceDataListAddDaili("2", id);
    },
    onChangeDailiCityId(id, name) {
      this.city_add_id = id;
      this.city_add_name = name;
      this.getProvinceDataListAddDaili("3", id);
    },

    async getProvinceDataListAddDaili(t, p) {
      let res = await provinceCityArea({ type: t, pid: p });
      if (res.code === 10000) {
        if (t === "1") {
          this.provinceList = res.data;
        } else if (t === "2") {
          this.city_add_list = res.data;
        } else {
          this.regin_add_list = res.data;
        }
      }
    },

    //新增合伙人
    async getaddAdminPartnerData() {
      var form = {};
      var area1 = "";
      var city1 = "";
      var province1 = "";

      this.provinceList.map(item => {
        if (item.id == this.province_id_address) {
          province1 = item.name;
          return;
        }
      });

      this.city_id_address_list.map(cityItem => {
        if (cityItem.id == this.city_id_address) {
          city1 = cityItem.name;
          return;
        }
      });

      this.region_id_address_list.map(areaItem => {
        if (areaItem.id == this.region_id_address) {
          area1 = areaItem.name;
          return;
        }
      });
      // var arr = []
      var areaArr = [];
      this.region_id_arr.map((item, index) => {
        areaArr.push({
          region_id: item,
          region: this.region_arr[index],
          city: this.city_arr[index],
          city_id: this.city_id_arr[index],
          province: this.province_arr[index],
          province_id: this.province_id_arr[index]
        });
        // areaArr.push({region_id:item})
        // areaArr.push({region:this.region_arr[index]})

        // areaArr.push({city:this.city_arr[index]})
        // areaArr.push({city_id:this.city_id_arr[index]})
        // areaArr.push({province:this.province_arr[index]})
        // areaArr.push({})
        // arr.push(areaArr)
      });
      if (this.partner_type == 1) {
        form = {
          username: this.username,
          partner_type: 1,
          initial_money: this.initial_money,
          actual_money: this.actual_money,
          wait_money: this.wait_money,
          area: area1,
          city: city1,
          province: province1,
          address: this.address,
          company_license: this.company_license,
          self_front_card: this.self_front_card,
          company_phone: this.company_phone,
          company_contact: this.company_contact,
          company_name: this.company_name,
          company_legalname: this.company_legalname,
          areas: JSON.stringify(areaArr),
          is_direct: this.isDirect ? 1 : 0,
        };
      } else {
        form = {
          username: this.username,
          partner_type: 2,
          initial_money: this.initial_money,
          actual_money: this.actual_money,
          wait_money: this.wait_money,
          area: area1,
          city: city1,
          province: province1,
          address: this.address,
          company_license: this.company_license,
          self_front_card: this.self_front_card,
          self_phone: this.company_phone,
          self_name: this.company_contact,
          company_name: this.company_name,
          company_legalname: this.company_legalname,
          areas: JSON.stringify(areaArr),
          is_direct: this.isDirect ? 1 : 0,
        };
      }
      let res = await addAdminPartner(form);
      if (res.code === 10000) {
        this.$message.success(res.message);
        this.cancelAddPartner();
        this.getpartnerProvinceSearchData();
      } else {
        this.$message.error(res.message);
      }
    },
    getFile(file) {
      this[file.name] = file.files.length > 0 ? file.files[0].url : "";
    },
    tc() {
      return "text-align:center; color:#333333; font-size:12px;";
    },
    tccolor() {
      return "text-align:center;background-color:#f5f5f5; font-size:14px;";
    },
    showRedpacketList(item) {
        this.userForm.id = item.id;
        this.isShowRedpacketList = true;

    }
  }
};
</script>

<style lang="scss" scoped>
.shop {
  padding: 20px;
  position: relative;
}
.kuang {
  margin-top: 5px;
  float: left;
  width: 25%;
  height: 72px;
  text-align: center;
  border: 1px solid #999;
  .top_p {
    color: #999;
    font-size: 13px;
    margin: 12px 0;
  }
  .bottom_p {
    color: #333;
    font-size: 17px;
  }
}
.el-icon-check {
  float: right;
  font-size: 10px;
  font-weight: 700;
}
.pagination {
  float: right;
  margin: 20px 0;
}
.icon_cate {
  float: left;
  margin-left: 14px;
}
.el-icon-remove-outline {
  float: right;
  margin-top: 6px;
  color: #f4222d;
  margin-right: 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
}
.forAreas {
  border: 1px solid black;
  width: 90%;
  margin: 5px auto;
  height: 40px;
  text-align: center;
  line-height: 40px;
}
.forAreas span {
  width: 20px;
  height: 20px;
  border-radius: 20px;
  background-color: #000;
  display: inline-block;
  line-height: 20px;
  color: #fff;
}
</style>
